//
//  UIButton+Extension.swift
//  sinaWeibo
//
//  Created by 浅爱 on 16/3/18.
//  Copyright © 2016年 y. All rights reserved.
//

import UIKit

extension UIButton {

    // 背景图片 + 图片的按钮显示样式
    class func buttonWithImage(imageName: String, backImageName: String) -> UIButton {
    
        // UIButton()自定义样式
        let btn = UIButton()
        
        btn.setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
        
        btn.setBackgroundImage(UIImage(named: backImageName + "_highlighted"), forState: .Highlighted)
        
        btn.setImage(UIImage(named: imageName), forState: .Normal)
        
        btn.setImage(UIImage(named: imageName + "t_highlighted"), forState: .Highlighted)
        
        btn.sizeToFit()
        
        
        return btn

    }
    
    
    // 背景图片 + 文字样式
    class func buttonWithTitle(title: String, backImageName: String, textColor: UIColor, fontOfSize: CGFloat) -> UIButton {
        
        let btn = UIButton()
        
        // 背景图片
        btn.setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
        
        // 按钮字体样式
        btn.setTitle(title, forState: .Normal)
        
        btn.setTitleColor(textColor, forState: .Normal)
        
        btn.titleLabel?.font = UIFont.systemFontOfSize(fontOfSize)
        
        btn.sizeToFit()
        
        
        return btn
        
    }


}





